package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.LikeBean;
import com.lwj.liwanjia.impl.LikeView;
import com.lwj.liwanjia.model.LikeModel;

import rx.Subscriber;

/**
 * 猜你喜欢
 */

public class LikePresenter {
    private LikeModel likeModel;
    private LikeView likeView;

    public LikePresenter(LikeView likeView) {
        this.likeView = likeView;
        likeModel = new LikeModel();
    }

    public void getLikeData() {
        if (likeView != null) {
            likeModel.getLikeData(new Subscriber<LikeBean>() {
                @Override
                public void onCompleted() {
                    likeView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    likeView.showError((Exception) e);
                    likeView.hideProgress();
                }

                @Override
                public void onNext(LikeBean likeBean) {
                    likeView.getLikeData(likeBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    likeView.showProgress();
                }
            });
        }
    }
}
